package com.jming.yygh.hosp.controller;

import com.jming.yygh.common.result.Result;
import com.jming.yygh.hosp.service.ScheduleService;
import com.jming.yygh.model.hosp.Schedule;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author jming
 * @version 0.0.1
 * @date 2021/05/06
 */
@Api(tags = "排班信息接口")
//@CrossOrigin  // 允许跨域访问
@RestController   // Rest风格注入
@RequestMapping("/admin/hosp/schedule")
public class ScheduleController {

    @Resource
    private ScheduleService scheduleService;

    /**
     * 根据医院编号与科室编号查询排班信息
     * @param page 当前页
     * @param limit 每页记录数
     * @param hoscode 医院编号
     * @param depcode 科室编号
     * @Author jming
     * @Date 2021/5/6
     * @return Result 查询结果集
     */
    @ApiOperation(value = "查询排班规则数据")
    @GetMapping("getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result getScheduleRule(@PathVariable long page,
                                  @PathVariable long limit,
                                  @PathVariable String hoscode,
                                  @PathVariable String depcode) {

        Map<String, Object> map = scheduleService.getRuleSchedule(page, limit, hoscode, depcode);

        return Result.ok(map);
    }

    /**
     * 根据医院编号、科室编号和工作日期查询排班详细信息
     * @param hoscode 医院编号
     * @param depcode 科室编号
     * @param workDate 工作日期
     * @Author jming
     * @Date 2021/5/6
     * @return Result 查询结果
     */
    @ApiOperation(value = "查询排班详细信息")
    @GetMapping("getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public Result getScheduleDetail(@PathVariable String hoscode,
                                    @PathVariable String depcode,
                                    @PathVariable String workDate) {

        List<Schedule> list = scheduleService.getDetailSchedule(hoscode, depcode, workDate);

        return Result.ok(list);
    }
}
